// index.js
import {getBanner,getAnnouncement,getIndexList,getProducts} from "../../apis/index"
Page({
  data: {
    // 轮播图
    imgUrls: [],
    // 公告
    marquee2: {
      speed: 60,
      loop: -1,
      delay: 0,
    },
    content:'',
    // 宫格
    tgrid:[
      {id:1, text:"分类名称", image:"/image/文件.jpg",},
      {id:2, text:"分类名称", image:"/image/分类.jpg",},
      {id:3, text:"分类名称", image:"/image/咖啡.jpg",},
      {id:4, text:"分类名称", image:"/image/分类2.jpg",},
      {id:5, text:"分类名称", image:"/image/文件.jpg"},
      {id:6, text:"分类名称", image:"/image/分类.jpg",},
      {id:7, text:"分类名称", image:"/image/咖啡.jpg",},
      {id:8, text:"分类名称", image:"/image/分类2.jpg",},
    ],
    tgrid1:[],
    // 产品列表
    list:[
      {id:1,text:"咖啡机咖啡机1",text1:"产品简介:产品简介简介产品简介简产品简",text2:"销量265",
      text3:"￥200/月 押金:￥500",image:"/image/咖啡机1.jpg"},
      {id:2,text:"咖啡机咖啡机1",text1:"产品简介:产品简介简介产品简介简产品简",text2:"销量265",
      text3:"￥200/月 押金:￥500",image:"/image/咖啡机2.jpg"},
      {id:3,text:"咖啡机咖啡机1",text1:"产品简介:产品简介简介产品简介简产品简",text2:"销量265",
      text3:"￥200/月 押金:￥500",image:"/image/咖啡机3.jpg"},
      {id:4,text:"咖啡机咖啡机1",text1:"产品简介:产品简介简介产品简介简产品简",text2:"销量265",
      text3:"￥200/月 押金:￥500",image:"/image/咖啡机4.jpg"},
    ],
    Productslist:[]
  },
  // 获取接口banner
  async onLoad(options) {
    //  获取首页轮播图
    const indexBanner = await getBanner()
    const imgUrls =   indexBanner.data.image
    this.setData({imgUrls})
    // 公告
    const Announcement = await getAnnouncement()
    const content =   Announcement.data.list
    this.setData({content})
    // 商品列表
    const Menulist = await getIndexList()
    const tgrid1 = Menulist.data.list
    this.setData({tgrid1})
    // 商品列表
    const Products = await getProducts()
    const Productslist = Products.data.list
    this.setData({Productslist})
  },
    // 跳产品详情
  goDetails(){
    wx.navigateTo({
      url: '/pages/details/details',
    })
  }
})

